<?php

namespace App\Admin\Forms\Settings;

use Encore\Admin\Widgets\Form;
use Illuminate\Http\Request;
use function app\Helpers\sys;

class Website extends BaseTabForm
{
    /**
     * The form title.
     *
     * @var string
     */
    public $title = '网站设置';

    /**
     * Handle the form request.
     *
     * @param Request $request
     *
     * @return \Illuminate\Http\RedirectResponse
     */
    public function handle(Request $request)
    {
        parent::handle($request);

        admin_success('Processed successfully.');

        return back();
    }

    /**
     * Build a form here.
     */
    public function form()
    {
        $this->text('subject_name', '主体名称')->rules('required');
        $this->text('subject_address', '主体地址')->rules('required');
        $this->text('contact_person', '联系人')->rules('required');
        $this->text('contact_phone', '联系方式')->rules('required');
        $this->text('subject_code', '主体身份码')->rules('required');
        $this->text('website_title', '网站标题')->rules('required')->help('网页的标题');
        $this->text('website_name', '网站名')->rules('required')->help('网站的名称');
        $this->text('website_url', '网站主页')->rules('required');
    }

    /**
     * The data of the form.
     *
     * @return array $data
     */
    public function data()
    {
        return [
            'subject_name'    => sys('subject_name'),
            'subject_address' => sys('subject_address'),
            'contact_person'  => sys('contact_person'),
            'contact_phone'   => sys('contact_phone'),
            'subject_code'    => sys('subject_code'),
            'website_title'   => sys('website_title'),
            'website_name'    => sys('website_name'),
            'website_url'     => sys('website_url'),
        ];
    }
}
